import { request } from '@umijs/max';
import * as API from "@/services";

export async function queryRoles(params: API.RolePageQueryParams): Promise<API.RespPageResult<API.Role>> {
    return request('/api/v1/role', {
        params,
    });
}

export async function queryRole(bizId: API.EntityId): Promise<API.RespResult<API.Role>> {
    return request(`/api/v1/role/${bizId}`);
}

export async function createRole(entity: API.Role_Create): Promise<API.RespResult<any>> {
    return request(`/api/v1/role`, {
        method: 'POST',
        data: entity,
    });
}

export async function modifyRole(entity: API.Role_Modify): Promise<API.RespResult<any>> {
    return request(`/api/v1/role/${entity.id}`, {
        method: 'PUT',
        data: entity,
    });
}

export async function patchRole(entity: API.Role_Patch): Promise<API.RespResult<any>> {
    return request(`/api/v1/role/${entity.id}`, {
        method: 'PATCH',
        data: entity,
    });
}

export async function deleteRole(bizId: API.EntityId): Promise<API.RespResult<any>> {
    return request(`/api/v1/role/${bizId}`, {
        method: 'DELETE',
    });
}

export async function deleteRoles(bizIds: API.EntityId[]): Promise<API.RespResult<any>> {
    return request(`/api/v1/role`, {
        method: 'DELETE',
        data: {
            ids: bizIds,
        },
    });
}
